package com.powerteam.service.crm;

import com.github.pagehelper.PageInfo;
import com.powerteam.exception.BusinessException;
import com.powerteam.handler.GlobalExceptionHandler;
import com.powerteam.model.crm.ContactsRole;
import com.powerteam.model.crm.Opportunity;
import com.powerteam.vo.Result;
import com.powerteam.vo.crm.QueryOpportunityVO;

import java.util.List;
import java.util.Map;

/**
 * 机会相关服务接口
 *
 * @author jinming.zhang
 * @version 0.0.1
 * @date 2021/12/30
 */
public interface OpportunityService {


    /**
     * 创建业务机会
     *
     * @param opportunity
     * @return Result
     * @Author jinming.zhang
     * @Date 2022/1/6
     */
    Result insert(Opportunity opportunity);

    /**
     * 分页查询机会信息
     *
     * @param vo
     * @return PageInfo<Opportunity>
     * @Author jinming.zhang
     * @Date 2022/1/7
     */
    PageInfo<Opportunity> find(QueryOpportunityVO vo);

    /**
     * 根据Id查询业务机会详情
     *
     * @param opportunityId
     * @return Opportunity
     * @Author jinming.zhang
     * @Date 2022/1/7
     */
    Opportunity findById(Integer opportunityId);

    /**
     * 更新/修改业务机会
     *
     * @param opportunity
     * @return Result
     * @Author jinming.zhang
     * @Date 2022/1/7
     */
    Result update(Opportunity opportunity);

    /**
     * 添加联系人信息
     *
     * @param contactsRole
     * @return Result
     * @Author jinming.zhang
     * @Date 2022/1/7
     */
    Result insertContactsRole(ContactsRole contactsRole);

    /**
     * @param contactsRole
     * @return Result
     * @Author jinming.zhang
     * @Date 2022/1/8
     */
    Result updateContactsRole(ContactsRole contactsRole);

    /**
     * 移除联系人角色
     *
     * @param contactsRole
     * @return Result
     * @Author jinming.zhang
     * @Date 2022/1/7
     */
    Result deleteContactsRole(ContactsRole contactsRole);

    /**
     * 删除业务机会
     *
     * @param opportunity
     * @return Result
     * @Author jinming.zhang
     * @Date 2022/1/7
     */
    Result delete(Opportunity opportunity);

    /**
     * 本月我参与的业务机会
     *
     * @param vo
     * @return List<Map>
     * @Author jinming.zhang
     * @Date 2022/1/8
     */
    List<Map<String, Integer>> findMonthlyFunnel(QueryOpportunityVO vo);

    /**
     * 本月我的转化情况
     *
     * @param vo
     * @return List<Map < String, Integer>>
     * @Author jinming.zhang
     * @Date 2022/1/8
     */
    List<Map<String, Integer>> findMonthlyConversion(QueryOpportunityVO vo);

    /**
     * 查询将要结束的业务机会(最近一周没有关闭的业务机会)
     *
     * @param vo
     * @return List<Opportunity>
     * @Author jinming.zhang
     * @Date 2022/1/8
     */
    List<Opportunity> findRecentlyClosing(QueryOpportunityVO vo);
}
